package tech.aistar.clothesspringboot.controller;



import jakarta.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.HttpRequestHandler;
import org.springframework.web.bind.annotation.*;
import tech.aistar.clothesspringboot.pojo.RentOrder;
import tech.aistar.clothesspringboot.pojo.result.ResultReturn;
import tech.aistar.clothesspringboot.service.RentOrderService;

import java.util.List;

@RestController
@RequestMapping("/rentOrder")
@Slf4j
public class RentOrderContrroller {
    @Autowired private RentOrderService rentOrderService;

    @GetMapping("/getRentOrderByUserId")
    public List<RentOrder> getRentOrderByUserId(Integer userId){
        return rentOrderService.getRentOrderByUserId(userId);
    }

    @PostMapping("/insertRentOrder")
    public ResultReturn<Integer> insertRentOrderByUserId(@RequestBody RentOrder rentOrder, HttpServletRequest request){
        Integer userId = (Integer) request.getAttribute("userId");
        rentOrder.setUserId(userId);
        return rentOrderService.insertRentOrderByUserId(rentOrder);
    }
}
